package cn.kgc.springbootday0102;

import cn.kgc.springbootday0102.entity.Student;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

//  springboot项目的入口类   启动类
/*
*   @SpringBootApplication   组合注解
*    1.@ComponentScan                包扫描     默认包扫描位置  启动类所在包
*    2.@EnableAutoConfiguration     开启自动配置  spring  springmvc   第三方依赖的配置
*    3.@SpringBootConfiguration    @Configuration      标识当前类是springboot工程的配置配置类
*
* */

// @ComponentScan(basePackages = "cn.kgc.springbootday01")
// @Configuration
// @EnableAutoConfiguration
@SpringBootApplication
public class Springbootday0101Application {

	public static void main(String[] args) {
		//  创建spring的工厂   extends ApplicationContext
		ApplicationContext applicationContext= SpringApplication.run(Springbootday0101Application.class, args);
		Student student = applicationContext.getBean("student", Student.class);
		System.out.println("student = " + student);
	}

	@Bean
    public Student  student(){
		Student student = new Student();
		student.setName("spring");
		student.setAge(20);
		return student;
	}

}
